package com.elai.tags.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elai.common.annotation.Log;
import com.elai.common.core.controller.BaseController;
import com.elai.common.core.domain.AjaxResult;
import com.elai.common.enums.BusinessType;
import com.elai.tags.domain.BaseUserGroupTaskDetail;
import com.elai.tags.service.IBaseUserGroupTaskDetailService;
import com.elai.common.utils.poi.ExcelUtil;
import com.elai.common.core.page.TableDataInfo;

/**
 * 分群任务调度记录Controller
 * 
 * @author elai
 * @date 2021-07-30
 */
@RestController
@RequestMapping("/tags/taskdetail")
public class BaseUserGroupTaskDetailController extends BaseController
{
    @Autowired
    private IBaseUserGroupTaskDetailService baseUserGroupTaskDetailService;

    /**
     * 查询分群任务调度记录列表
     */
    @PreAuthorize("@ss.hasPermi('tags:taskdetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseUserGroupTaskDetail baseUserGroupTaskDetail)
    {
        startPage();
        List<BaseUserGroupTaskDetail> list = baseUserGroupTaskDetailService.selectBaseUserGroupTaskDetailList(baseUserGroupTaskDetail);
        return getDataTable(list);
    }

    /**
     * 导出分群任务调度记录列表
     */
    @PreAuthorize("@ss.hasPermi('tags:taskdetail:export')")
    @Log(title = "分群任务调度记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BaseUserGroupTaskDetail baseUserGroupTaskDetail)
    {
        List<BaseUserGroupTaskDetail> list = baseUserGroupTaskDetailService.selectBaseUserGroupTaskDetailList(baseUserGroupTaskDetail);
        ExcelUtil<BaseUserGroupTaskDetail> util = new ExcelUtil<BaseUserGroupTaskDetail>(BaseUserGroupTaskDetail.class);
        return util.exportExcel(list, "分群任务调度记录数据");
    }

    /**
     * 获取分群任务调度记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('tags:taskdetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(baseUserGroupTaskDetailService.selectBaseUserGroupTaskDetailById(id));
    }

    /**
     * 新增分群任务调度记录
     */
    @PreAuthorize("@ss.hasPermi('tags:taskdetail:add')")
    @Log(title = "分群任务调度记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseUserGroupTaskDetail baseUserGroupTaskDetail)
    {
        return toAjax(baseUserGroupTaskDetailService.insertBaseUserGroupTaskDetail(baseUserGroupTaskDetail));
    }

    /**
     * 修改分群任务调度记录
     */
    @PreAuthorize("@ss.hasPermi('tags:taskdetail:edit')")
    @Log(title = "分群任务调度记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseUserGroupTaskDetail baseUserGroupTaskDetail)
    {
        return toAjax(baseUserGroupTaskDetailService.updateBaseUserGroupTaskDetail(baseUserGroupTaskDetail));
    }

    /**
     * 删除分群任务调度记录
     */
    @PreAuthorize("@ss.hasPermi('tags:taskdetail:remove')")
    @Log(title = "分群任务调度记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseUserGroupTaskDetailService.deleteBaseUserGroupTaskDetailByIds(ids));
    }
}
